package ru.hashcode.hashdroid.proxy;

import java.util.ArrayList;
import java.util.List;

import android.content.res.Resources;

import ru.hashcode.hashdroid.R;
import ru.hashcode.hashdroid.ResourcesHandler;

public class HashCode {
	private static HashCode instance = new HashCode();
	public static HashCode getInstance(){
		return instance;
	}
	private HashCode(){		
	}
	public List<Question> getData(int tab, int sort, int length){
		switch(tab){
		case Tab.Main:
			return getDataFromMainTab(sort, length);
		case Tab.Question:
			return getDataFromQuestionTab(sort, length);
		case Tab.Users:
			return getDataFromUserTab(sort, length);
		case Tab.Tags:
			return getDataFromTagsTab(sort, length);
		case Tab.Unanswered:
			return getDataFromUnansweredTab(sort, length);
		default:
			throw new RuntimeException("Wrong Tab param");			
		}
	}
	private List<Question> getDataFromMainTab(int sort, int length){
		
		Resources res = ResourcesHandler.getResources();

		User ironvbif = new User(res.getString(R.string.user1), 66, 0);
		User cybergnom = new User(res.getString(R.string.user2), 3000, 0);
		User murmur = new User(res.getString(R.string.user3), 106, 0);
		
		Question q1 = new Question(ironvbif, res.getString(R.string.question1head),
									res.getString(R.string.question1text));
		q1.addChild(new Answer(cybergnom, res.getString(R.string.answer11)));
		
		Question q2 = new Question(ironvbif, res.getString(R.string.question2head),
									res.getString(R.string.question2text));
		Answer ans21 = new Answer(cybergnom, res.getString(R.string.answer21));
		ans21.addChild(new Comment(ironvbif, res.getString(R.string.comment211)));
		ans21.addChild(new Comment(ironvbif, res.getString(R.string.comment212)));
		q2.addChild(ans21);
		
		Question q3 = new Question(ironvbif, res.getString(R.string.question3head),
									res.getString(R.string.question3text));
		
		Answer ans31 = new Answer(murmur, res.getString(R.string.answer31));
		
		ans31.addChild(new Comment(ironvbif, res.getString(R.string.comment311)));
		q3.addChild(ans31);
		
		List<Question> ret = new ArrayList<Question>();
		ret.add(q1);
		ret.add(q2);
		ret.add(q3);
		ret.add(q1);
		ret.add(q2);
		ret.add(q3);
		ret.add(q1);
		ret.add(q2);
		ret.add(q3);
		ret.add(q1);
		ret.add(q2);
		ret.add(q3);
		ret.add(q1);
		ret.add(q2);
		ret.add(q3);
		return ret;
	}
	private List<Question> getDataFromQuestionTab(int sort, int length){
		//return null;
		return getDataFromMainTab(sort, length);
	}
	private List<Question> getDataFromUserTab(int sort, int length){
		//return null;
		return getDataFromMainTab(sort, length);
	}
	private List<Question> getDataFromTagsTab(int sort, int length){
		//return null;
		return getDataFromMainTab(sort, length);
	}
	private List<Question> getDataFromUnansweredTab(int sort, int length){
		//return null;
		return getDataFromMainTab(sort, length);
	}
}
